import Vue from 'vue'
import App from './App.vue'
import router from './router'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'     //导入axios文件

// 用axios的拦截器，给每个请求自动地加上一个请求头
axios.interceptors.request.use(
  config =>{
    let token = localStorage.getItem("c-token")
    if(token){
      config.headers.token = token  // {headers:{'token':token}}
    }
    return config
  }
)

Vue.prototype.$axios = axios  //$axios 相当于配置一个axios的全局变量

Vue.use(ElementUI);

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
